package com.itcast.mapper;

import com.github.pagehelper.Page;
import com.itcast.pojo.Clazz;
import com.itcast.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {
    /**
     * 查询班级信息(条件)
     * @param param
     * @return
     */
    Page<Clazz> listQuery(ClazzQueryParam param);

    /**
     * 删除班级
     * @param id
     * @return
     */
    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);

    /**
     * 新增班级
     * @return
     */
    void add(Clazz clazz);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz where id = #{id};")
    Clazz getById(Integer id);

    /**
     * 修改班级
     * @return
     */
    void update(Clazz clazz);

    /**
     * 查询所有班级
     * @return
     */
    @Select("select id, name, room, begin_date, end_date, master_id, subject, create_time, update_time from clazz;")
    List<Clazz> list();
}
